package org.jpush.utils;

public class StopWatch
{
	// Use nano seconds here
	private static final double QPFrequency = 1000000.00;
	private long mStartCounter;
	private long mLastCounter;

	public StopWatch()
	{
		mStartCounter = System.nanoTime();
	    reset();
	}

	public void reset()
	{
		mLastCounter = System.nanoTime();
	}

	public double getElapsedTime()
	{
		return getElapsedTime(true);
	}

	public double getElapsedTime(boolean blnStart)
	{
	    long curCounter = System.nanoTime();
	    long mElapsedTime = (curCounter - (blnStart ? mStartCounter :  mLastCounter));

	    if(!blnStart)
	    {
	        reset();
	    }

	    return (double)mElapsedTime / QPFrequency;
	}
}
